<template>
  <div class="Grouppurchase">
    经纪人管理
    <p>
      搜索:
      <input type="text" placeholder="经纪人名称" v-model="value" @input="tgsearch(value)" />
      <button>查询</button>
      状态:
      <select v-model="value1" @click="tgtype(value1)">
        <option v-for="(item,index) in select1" :key="index">{{item}}</option>
      </select>
    </p>

    <!-- <el-table :data="tableData2" border style="width: 100%">
      <el-table-column fixed prop="id" label="序号" width="50"></el-table-column>
      <el-table-column prop="number" label="图片" width="130"></el-table-column>
      <el-table-column prop="name" label="楼盘名称" width="130"></el-table-column>
      <el-table-column prop="area" label="楼盘地址" width="230"></el-table-column>
      <el-table-column prop="myname" label="发起人" width="80"></el-table-column>
      <el-table-column prop="newtime" label="更新时间" width="230"></el-table-column>
      <el-table-column prop="state" label="状态" width="150"></el-table-column>
      <el-table-column fixed="right" label="操作" width="100">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>-->

    <table>
      <thead>
        <tr>
          <th>序号</th>
          <th>图片</th>
          <th>楼盘名称</th>
          <th>楼盘地址</th>
          <th>发起人</th>
          <th>起始时间</th>
          <th>状态</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(item,index) in tableData2" :key="index">
          <td>{{item.id}}</td>
          <td>{{item.number}}</td>
          <td>{{item.name}}</td>
          <td>{{item.area}}</td>
          <td>{{item.myname}}</td>
          <td>{{item.newtime}}</td>
          <td>{{item.state}}</td>
          <td>
            <span @click="Del(item.id)">删除</span>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
import { tableData2 } from "../../../api/index";
import axios from "axios";

export default {
  data() {
    return {
      tableData2: [],
      value: "",

      value1: "请选择",
      select1: ["请选择", "开启", "关闭"],

      search: ""
    };
  },
  created() {
    this.tabledata2();
  },
  methods: {
    handleClick(row) {
      console.log(row);
    },
    tabledata2() {
      tableData2().then(res => {
        if (res.data.code === 0) {
          this.$router.push("/login");
          this.$toast(res.data.msg);
        } else {
          this.tableData2 = res.data.data;
        }
      });
    },

    //类型赛选数据
    tgtype(value1) {
      axios({
        url: "/api/tgtype",
        method: "post",
        data: {
          value1: value1
        }
      }).then(res => {
        if (res.data.code === 1) {
          this.tabledata2();
        } else {
          this.tableData2 = res.data.data;
        }
      });
    },
    //搜索
    tgsearch(value) {
      axios({
        url: "/api/tgsearch",
        method: "post",
        data: {
          value: value
        }
      }).then(res => {
        this.tableData2 = res.data.data;
      });
    },

   //删除数据
    Del(id) {
      axios({
        url: "/api/tableDataDel2",
        method: "post",
        data: {
          id: id
        }
      }).then(res => {
        //调用函数
        this.tabledata2();
      });
    }


  }
};
</script>

<style lang="scss" scoped>
.Grouppurchase {
  width: 100%;
  height: 100%;
  table {
    width: 99%;
    margin-left: 1px;
    tr {
      th {
        text-align: center;
        height: 70px;
        line-height: 70px;
      }
      td {
        border: 1px solid rgb(235, 231, 231);
        height: 55px;
        text-align: center;
      }
    }
  }
}
</style>